package com.yz.group1.group_1.controller;

import com.yz.group1.group_1.entity.Hospitalization2;
import com.yz.group1.group_1.service.Hospitalization2Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/hospitalization")
public class Hospitalization2Controller {

    @Autowired
    private Hospitalization2Service hospitalization2Service;

    /**
     * 获取所有住院信息列表
     */
    @GetMapping
    public List<Hospitalization2> listAll() {
        return hospitalization2Service.listAll();
    }

    /**
     * 更新住院信息
     */
    @PostMapping("/update")
    public boolean update(@RequestBody Hospitalization2 hospitalization2) {
        return hospitalization2Service.update(hospitalization2);
    }

    /**
     * 根据ID删除住院信息
     */
    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Integer id) {
        return hospitalization2Service.delete(id);
    }

    /**
     * 添加新的住院信息
     */
    @PostMapping("/add")
    public boolean add(@RequestBody Hospitalization2 hospitalization2) {
        return hospitalization2Service.add(hospitalization2);
    }
}